<template>
  <transition name="fade">
    <div class="dialog-wrap" v-if="showDialog">
      <div
        class="content"
        :class="typeClass"
        :style="'top:' + top + ';width:' + width + ';height:' + height"
      >
        <div class="title">{{ title }}</div>
        <div class="close" @click="close">x</div>
        <iframe :src="src" frameborder="0"></iframe>
      </div>
    </div>
  </transition>
</template>
<script>
  export default {
    name: "MyDialog",
    components: {},
    props: {
      title: {
        type: String,
        default: () => "title",
      },
      top: {
        type: String,
        default: () => "10vh",
      },
      width: {
        type: String,
        default: () => "1400px",
      },
      height: {
        type: String,
        default: () => "500px",
      },
      show: {
        type: Boolean,
        default: () => false,
      },
      src: {
        type: String,
        default: () => "",
      },
    },
    data() {
      return {
        // 1:mobile 2pc
        type: 1,
        showDialog: this.show,
      };
    },
    created() {},
    mounted() {
      window.addEventListener("keydown", (event) => {
        console.log("event", event);
        if (event.keyCode == 27) {
          this.close();
        }
      });
    },
    computed: {
      typeClass() {
        return this.type == 1 ? "mobile" : "pc";
      },
      // showDialog() {
      //   return this.show;
      // },
    },
    watch: {},
    methods: {
      handleShow() {
        this.showDialog = true;
      },
      close() {
        this.showDialog = false;
      },
    },
  };
</script>
<style lang="scss" scoped>
  .dialog-wrap {
    position: fixed;
    z-index: 999999;
    background-color: rgba($color: #0d1326cf, $alpha: 0.6);
    top: 0;
    right: 0;
    left: 0;
    bottom: 0;
  }
  .close {
    position: absolute;
    top: 10px;
    right: 20px;
    z-index: 99999999999;
    cursor: pointer;
  }

  .content {
    z-index: 99999999;
    position: relative;
    margin: 0 auto;
    box-sizing: border-box;
    background-color: #060712;
    padding: 10px 20px 20px;
  }
  .title {
    line-height: 40px;
  }
  .mobile {
    padding: 0 465px;
  }
  iframe {
    width: 100%;
    height: 100%;
  }
  .fade-enter {
    opacity: 0;
  }
  .fade-enter-active {
    transition: opacity 0.3s;
  }
  .fade-leave-to {
    opacity: 0;
  }
  .fade-leave-active {
    transition: opacity 0.3s;
  }
</style>
